<html>
	<body>
	<table>
			<tr>
				<td colspan="2" id="pageheader">
					HEALTH INFORMATION SYSTEMS
				</td>
			</tr>
			<tr>
				<td id="mainnav">
					<div class="menuitem">Community</div>
					<div class="menuitem">Subdistricts</div>
					<div class="menuitem"></div>
					<div class="menuitem"></div>
					<div class="menuitem"></div>
				
				</td>
				<td id="content">
					<div id="divPageMenu">
						<!--<span class="menuitem" >User accounts</span>
						<input type="text" id="txtSearch">
						<span class="menuitem">search</span>	-->	
					</div>
					<!--<div id="divStatus" class="status">
						Welcome to the Health Information System-->
					</div>
					<div id="divContent">
						<table class="reportTable" width="100%">
							<tr class="header" >
								<td>community Details</td>
								<td></td>
							</tr>

	<!--	<form action="community_search.php" method="GET">
        <input type="text" name="community_name" /><br />
      <input type="submit" name="submit" value="Search" />
      </form> -->

<?php
	
	
$community_name = "";
if(isset($_REQUEST["community_name"])){
$community_name = $_REQUEST["community_name"];
}

	include("community.php");
	$obj = new community();
	if(!$obj -> search_community($community_name)){
	echo mysql_error($obj->link);

		exit();
	}

//	$community_name = mysql_real_escape_string($_REQUEST['community_name']);    

	//$r_query = mysql_query($sql);
	
	$row = $obj->fetch();
	

		
	if(is_null($row['community_name'])){
		//return false;
		echo"<p>can not find a community with that name</p>";
	}

	else{
		
		$row = $obj->fetch();
	$row_counter = 0;
	while($row){
	
			
		if($row_counter%2==0){
			$style=" class='row1' ";
		}else{
			$style=" class='row2'  ";
		}
		
		$id = $row['community_id'];
		echo "<tr $style >";
		echo "<td>";
			echo $row["community_id"];
		echo "</td>";
		
		echo "<td>";
			echo "<a href = 'community_detail.php?community_id=$id'>" . $row["community_name"] . "</a>";
		echo "</td>";
		
		echo ("<td>");
				echo ("<a target='_blank' href='communityedit.php?community_id=$id'>edit</a>");
				echo ("</td>");
				
				echo ("<td><a target='_blank' href='community_delete.php?community_id=$id'>delete</a>");
				echo "</tr>";
		$row=$obj->fetch();
		$row_counter++;
	}
	}

?>

			</table>
					</div>
				</td>
			</tr>
			</table>
		
	
	</body>
</html> 